/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.team1160.breakaway.ballControl;

import com.team1160.breakaway.api.Constants;
import edu.wpi.first.wpilibj.Jaguar;

/**
 *
 * @author FireBird Robotics
 */
public class Dribbler {
    //Static fields
    ////////////////////////////////////////////////////////////////////////////
    //private static final Dribbler DEFAULT_DRIBBLER = new Dribbler();

    //instance fields
    ////////////////////////////////////////////////////////////////////////////
    protected Jaguar m_motor;
    protected boolean isOn = false;
    protected int s_speed;

    //constructors
    ////////////////////////////////////////////////////////////////////////////
    /**
     * Constructs basic dribbler from constants in the Constants package.
     */
    public Dribbler(){
         this.m_motor = new Jaguar(Constants.C_DRIBBLER_MOTOR);
         this.m_motor.setBounds(Constants.JAGUAR_MAX_LIMIT,
                Constants.JAGUAR_DEADBAND_TOP,
                Constants.JAGUAR_CENTER,
                Constants.JAGUAR_DEADBAND_BOT,
                Constants.JAGUAR_MIN_LIMIT);
         this.s_speed = -1;
    }
    
    //public instance methods
    ////////////////////////////////////////////////////////////////////////////
    /**
     * Starts the dribbler, if no speed has been choosen, sets the speed to the
     * default in the Constants package.
     */
    public void start(){
        this.isOn = true;
        if(this.s_speed == -1)
            this.m_motor.setRaw(Constants.SPEED_DRIBBLER_MOTOR);
        else
            this.m_motor.setRaw(s_speed);
    }

    /**
     * Stops the dribbler by setting it to the center of the constants package.
     */
    public void stop() {
        this.isOn = false;
        this.m_motor.setRaw(Constants.JAGUAR_CENTER);
    }

    /**
     * Returns if the dribbler is on or not
     * @return True if the dribbler is on, false if not.
     */
    public boolean isOn() {
        return this.isOn;
    }

    /**
     * Sets the new speed.
     * @param newSpeed that will be set.
     */
    public void setSpeed (int newSpeed) {
        this.s_speed = newSpeed;
    }

    /**
     * Returns the current set speed.
     * @return The return is the current speed, if its is -1, then speed has not
     * been set.
     */
    public double getSpeed () {
        return this.s_speed;
    }
}

